<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en">
<head>
    <title>My Facelets Page</title>
    <meta http-equiv="keywords" content="enter,your,keywords,here"/>
    <meta http-equiv="description"
          content="A short description of this page."/>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

    <!--<link rel="stylesheet" type="text/css" href="styles.css">-->
</head>
<body>
<ui:composition template="BackGeneral.xhtml">
    <ui:define name="content">
        <h:form>

            <ui:include src="/AjaxStatus2.xhtml"/>
            <p:dialog id="PartnerPanel" widgetVar="PartnerPanel" style="text-align:left" width="600">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="友情链接类型"></h:outputText>
                    </h:panelGroup>
                </f:facet>
                <p:outputPanel autoUpdate="true">
                    <p:dataTable value="#{listPartner.typeList}" var="type" paginator="true" paginatorPosition="bottom">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="名称"/>
                            </f:facet>
                            <h:inputText value="#{type.name}"></h:inputText>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="次序"/>
                            </f:facet>
                            <h:inputText value="#{type.ord}" size="3"></h:inputText>
                        </p:column>
                        <p:column style="text-align:center;">
                            <p:commandLink action="#{listPartner.deleteType}" value="删除">
                                <f:param name="tid" value="#{type.id}"/>
                            </p:commandLink>
                            <f:facet name="header">
                                <h:outputText value="删除"/>
                            </f:facet>
                        </p:column>
                    </p:dataTable>
                    <p:commandButton action="#{listPartner.batchUpdateType}" value="修改">
                    </p:commandButton>


                    <h:panelGrid columns="5">
                        <h:outputText value="名称："></h:outputText>
                        <h:inputText value="#{listPartner.pt.name}"/>
                        <h:outputText value="次序："></h:outputText>
                        <h:inputText value="#{listPartner.pt.ord}" size="3"/>
                        <p:commandButton action="#{listPartner.addType}" value="添加">
                        </p:commandButton>
                    </h:panelGrid>
                </p:outputPanel>
            </p:dialog>


            <div style="text-align: left; margin: 10px 0px 0px 0px; width: 98%;">
                <h:outputText id="outputText1"
                              styleClass="tit"
                              value="－友情链接－"/>
                <h:outputLink value="AAPartner.jspx">
                    <h:outputText value="添加链接"></h:outputText>
                </h:outputLink>
                &nbsp;&nbsp;&nbsp;
                <p:commandLink value="编辑友情链接类型" onclick="PartnerPanel.show()"/>

                <hr/>
                <p:dataTable paginator="true" paginatorPosition="bottom" id="dataTable1" styleClass="list"
                             style="width:100%"
                             value="#{listPartner.partnerList}" var="partner" rowIndexVar="row" rows="15">
                    <p:column>
                        <h:outputText value="#{row+1}"/>
                        <f:facet name="header">
                            <h:outputText value="序号"/>
                        </f:facet>
                    </p:column>
                    <p:column>
                        <h:outputText value="#{partner.name}"/>
                        <f:facet name="header">
                            <h:outputText value="名称"/>
                        </f:facet>
                    </p:column>
                    <p:column sortBy="#{partner.typeId}">
                        <h:outputText value="#{listPartner.partnerMap[partner.typeId]}"/>
                        <f:facet name="header">
                            <h:outputText value="类型"/>
                        </f:facet>
                    </p:column>
                    <p:column>
                        <h:outputLink value="AAPartner.jspx?id=#{partner.id}">
                            <h:outputText value="修改"/>
                        </h:outputLink>
                        <f:facet name="header">
                            <h:outputText value="修改"/>
                        </f:facet>
                    </p:column>
                    <p:column>
                        <p:commandLink actionListener="#{listPartner.delete}" update="@form"
                                       onclick="if (!confirm('确认要删除此友情链接吗？')) return false">
                            <f:param name="id" value="#{partner.id}"></f:param>
                            <h:outputText value="删除"/>
                        </p:commandLink>
                        <f:facet name="header">
                            <h:outputText value="删除"/>
                        </f:facet>
                    </p:column>
                </p:dataTable>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
</body>
</html>
